package com.six.library.model

import com.baomidou.mybatisplus.annotation.FieldStrategy
import com.baomidou.mybatisplus.annotation.TableField
import com.gitee.sunchenbin.mybatis.actable.annotation.*
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlCharsetConstant
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlEngineConstant

@Table(value = "flowers", comment = "鮮花種類")
@TableCharset(MySqlCharsetConstant.UTF8)
@TableEngine(MySqlEngineConstant.InnoDB)
class Flowers {
    @IsKey  //是否主键
    @IsAutoIncrement    //是否自增
    var id: Int = 0

    @Column(isNull = false, defaultValue = "")
    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)
    var name: String = ""

    @Column(name = "fLanguage", isNull = false, defaultValue = "")
    @TableField(value = "fLanguage", insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)

    var fLanguage: String = "" //花語

    @Column(isNull = false, defaultValue = "0")
    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)

    var price: Int = 0 //價格

    @Column(isNull = false, defaultValue = "0")
    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)

    var inventory: Int = 0 //剩餘庫存

    @Column(isNull = false, defaultValue = "")
    @TableField(insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)
    var target: String = ""

    @Column(name = "imgUrl", isNull = false, defaultValue = "")
    @TableField(value = "imgUrl", insertStrategy = FieldStrategy.NOT_EMPTY, updateStrategy = FieldStrategy.NOT_EMPTY)
    var imgUrl: String = ""

    constructor()

    companion object {}

    constructor(flowers: Flowers) : this() {
        this.name = flowers.name
        this.fLanguage = flowers.fLanguage
        this.price = flowers.price
        this.inventory = flowers.inventory
        this.target = flowers.target
    }

    override fun toString(): String {
        return "Flowers(id=$id, name='$name', fLanguage='$fLanguage', price=$price, inventory=$inventory, target='$target', imgUrl='$imgUrl')"
    }

}
